import { BaseModel } from '@/common/base/base.model';
import { Column, Entity, Index, OneToMany } from 'typeorm';
import { RoleResourceModel } from "@/module/role-resource/role-resource.model";

@Entity('ROLE', {
  synchronize: false,
}) // 角色
export class RoleModel extends BaseModel {
  @Column({
    comment: '名称',
    type: 'varchar',
    length: 250,
  })
  @Index('ROLE.name', { unique: true })
  name: string;

  @Column({
    comment: '描述',
    type: 'varchar',
    length: 500,
    default: '',
  })
  desc: string;

  @OneToMany(() => RoleResourceModel, roleResource => roleResource.role)
  roleResources: RoleResourceModel[];
}
